package com.muyi.biling.fragment.more;

import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.Toast;

import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

import javax.inject.Inject;

import autodagger.AutoComponent;
import autodagger.AutoInjector;
import com.muyi.biling.MyApp;
import com.muyi.biling.R;
import com.muyi.biling.SharedPreferencesHelper;
import com.muyi.biling.di.DaggerScope;
import com.muyi.biling.di.Injector;

/**
 * Created by developer on 18-1-25.
 */

@AutoComponent(
        dependencies = MyApp.class
)
@AutoInjector
@DaggerScope(ShopSettingFragment.class)
@EFragment(R.layout.frag_shop_setting)
public class ShopSettingFragment extends Fragment {

    @ViewById(R.id.frag_shop_et_logistics)
    EditText etLogistics;
    @ViewById(R.id.frag_shop_et_other)
    EditText etOther;
    @ViewById(R.id.frag_shop_et_title)
    EditText etTitle;

    @Inject
    SharedPreferencesHelper mShareHelper;

    @AfterInject
    void initDI() {
        Injector.initShopSettingFragmentComponent().inject(this);
    }

    @AfterViews
    void initView() {


    }

    @Click(R.id.frag_shop_btn_save)
    void saveSettings() {
        String strTitle = etTitle.getText().toString().trim();
        if (TextUtils.isEmpty(strTitle)) {
            Toast.makeText(getActivity(), "开单抬头不为空", Toast.LENGTH_SHORT).show();
            return;
        }

        String strOther = etOther.getText().toString().trim();

        mShareHelper.setData("title", strTitle);

        if (!TextUtils.isEmpty(strOther)) {
            mShareHelper.setData("other", strOther);
        }

//        mShareHelper.setData("logistics", strLogistics);

    }


}
